package com.zwf.controller.admin;

import com.zwf.result.Result;
import com.zwf.service.WorkSpaceService;
import com.zwf.vo.BusinessDataVO;
import com.zwf.vo.DishOverViewVO;
import com.zwf.vo.OrderOverViewVO;
import com.zwf.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @Author zwf
 * @date 2024/2/21 13:26
 */
@RestController
@RequestMapping("/admin/workspace")
@Api(tags = "工作台接口")
@Slf4j
public class WorkSpaceController {

    @Autowired
    WorkSpaceService workSpaceService;

    @GetMapping("/businessData")
    @ApiOperation("查询今日运营数据")
    public Result<BusinessDataVO> businessData(){
        log.info("查询今日运营数据");
        //获取今日日期
        LocalDate localDate=LocalDate.now();
        LocalDateTime begin=LocalDateTime.of(localDate, LocalTime.MIN);
        LocalDateTime end=LocalDateTime.of(localDate, LocalTime.MAX);
        return Result.success(workSpaceService.businessData(begin,end));
    }

    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单管理数据")
    public Result<OrderOverViewVO> overviewOrders(){
        log.info("查询订单管理数据");
        return Result.success(workSpaceService.overviewOrders());
    }

    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result<DishOverViewVO> overviewDishes(){
        log.info("查询菜品总览");
        return Result.success(workSpaceService.overviewDishes());
    }

    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        log.info("查询套餐总览");
        return Result.success(workSpaceService.overviewSetmeals());
    }
}
